<?php

/**
 * This is the model class for table "promosi".
 *
 * The followings are the available columns in table 'promosi':
 * @property integer $ID_PROMOSI
 * @property integer $ID_BUS
 * @property integer $ID_KERETA
 * @property integer $ID_TRAVEL
 * @property string $NAMA_PROMOSI
 * @property string $JENIS_PROMOSI
 * @property string $ISI_PROMOSI
 * @property integer $LAYANAN_SMSGATEWAY
 *
 * The followings are the available model relations:
 * @property KeretaApi $iDKERETA
 * @property Bus $iDBUS
 * @property PenyediaTravel $iDTRAVEL
 */
class Promosi extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Promosi the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'promosi';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ID_PROMOSI', 'required'),
			array('ID_PROMOSI, ID_BUS, ID_KERETA, ID_TRAVEL, LAYANAN_SMSGATEWAY', 'numerical', 'integerOnly'=>true),
			array('NAMA_PROMOSI', 'length', 'max'=>20),
			array('JENIS_PROMOSI', 'length', 'max'=>15),
			array('ISI_PROMOSI', 'length', 'max'=>150),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_PROMOSI, ID_BUS, ID_KERETA, ID_TRAVEL, NAMA_PROMOSI, JENIS_PROMOSI, ISI_PROMOSI, LAYANAN_SMSGATEWAY', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'iDKERETA' => array(self::BELONGS_TO, 'KeretaApi', 'ID_KERETA'),
			'iDBUS' => array(self::BELONGS_TO, 'Bus', 'ID_BUS'),
			'iDTRAVEL' => array(self::BELONGS_TO, 'PenyediaTravel', 'ID_TRAVEL'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_PROMOSI' => 'Id Promosi',
			'ID_BUS' => 'Id Bus',
			'ID_KERETA' => 'Id Kereta',
			'ID_TRAVEL' => 'Id Travel',
			'NAMA_PROMOSI' => 'Nama Promosi',
			'JENIS_PROMOSI' => 'Jenis Promosi',
			'ISI_PROMOSI' => 'Isi Promosi',
			'LAYANAN_SMSGATEWAY' => 'Layanan Smsgateway',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_PROMOSI',$this->ID_PROMOSI);
		$criteria->compare('ID_BUS',$this->ID_BUS);
		$criteria->compare('ID_KERETA',$this->ID_KERETA);
		$criteria->compare('ID_TRAVEL',$this->ID_TRAVEL);
		$criteria->compare('NAMA_PROMOSI',$this->NAMA_PROMOSI,true);
		$criteria->compare('JENIS_PROMOSI',$this->JENIS_PROMOSI,true);
		$criteria->compare('ISI_PROMOSI',$this->ISI_PROMOSI,true);
		$criteria->compare('LAYANAN_SMSGATEWAY',$this->LAYANAN_SMSGATEWAY);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}